package fanjingzhu.check.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import publics.model.ProposerGuarantee;
import publics.util.Page;
import fanjingzhu.check.dao.ProposerGuaranteeDao;
import fanjingzhu.check.service.ProposerGuaranteeService;

@Component("proposerGuaranteeService")
public class ProposerGuaranteeServiceImpl implements ProposerGuaranteeService{
	
	ProposerGuaranteeDao proposerGuaranteeDao;
	
	public ProposerGuaranteeDao getProposerGuaranteeDao() {
		return proposerGuaranteeDao;
	}
    @Resource(name="proposerGuaranteeDao")
	public void setProposerGuaranteeDao(ProposerGuaranteeDao proposerGuaranteeDao) {
		this.proposerGuaranteeDao = proposerGuaranteeDao;
		System.out.println("proposerGuaranteeDaoImpl inject in ProposerGuaranteeServiceImpl");
	}
    
    public Object saveGuarantee(ProposerGuarantee guarantee) {
		return this.proposerGuaranteeDao.save(guarantee);
	}

	public boolean deleteGuarantee(Integer guaranteeId) {
		return this.proposerGuaranteeDao.deleteById(guaranteeId);
	}
	public boolean updateGuarantee(ProposerGuarantee guarantee)
	throws Exception {
        return this.proposerGuaranteeDao.update(guarantee);
     }
	public List findById(int proposerId) {
		List ls=new ArrayList();
		ls.add(this.proposerGuaranteeDao.findById(proposerId));
		return ls;
	}

	public Page findByPage(Page page) {
		String sql="from ProposerGuarantee";
		int pageSize=page.getLimit();
		int offset=page.getStart();
		page.setRoot(proposerGuaranteeDao.findByPage(sql, offset, pageSize));
		page.setTotalProperty(proposerGuaranteeDao.findByCount(sql));
		return page;
	}

	
	

}
